package com.practice.car.cardataapp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.practice.car.cardataapp.entity.SuvAndMpvSalesRatio;
import com.practice.car.cardataapp.entity.TotalNationalSales;
import com.practice.car.cardataapp.entity.frontEnd.Form;
import com.practice.car.cardataapp.mapper.SuvAndMpvSalesRatioDao;
import com.practice.car.cardataapp.mapper.TotalNationalSalesDao;
import com.practice.car.cardataapp.service.TotalNationalSaleService;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * car-data-app project
 *
 * @author ZhangMingXing
 * @date 2020/9/6
 */
@Service
public class TotalNationalSaleServiceImpl extends ServiceImpl<TotalNationalSalesDao,TotalNationalSales> implements TotalNationalSaleService {
	@Override
	public List<Form> getSeries() {
		List<TotalNationalSales> list = this.list();
		SeriesUtil<TotalNationalSales> util = new SeriesUtil<>();
		util.setLegendSolver(e -> e.getNational());
		util.setFormSolver(e->new PieData(e.getNational(),e.getProportion()));
		return util.getSeries(list);
	}

	@Data
	@AllArgsConstructor
	class PieData {
		private String name;
		private double value;
	}
}
